import java.util.Scanner;

public class demo {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[][] arry = new int[n][n];
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < n; j++) {
                arry[i][j] = sc.nextInt();
            }
        }
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < n; j++) {
                System.out.print(arry[i][j] + " ");
            }
            System.out.println();
        }
        int num=0;
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < n; j++) {
                if (i==0 && j==n-1) {
                    num=num+arry[i][j];
                }
                else if (i==n-1 && j==0) {
                    num+=arry[i][j];
                }
                else if (i==j) {
                    num+=arry[i][j];
                }
                else if(j==n-i-1){
                    num+=arry[i][j];
                }
            }
        }
        System.out.println(num);
    }
}
